﻿
using UnityEngine;
using UnityEditor;
using UnityEngine.SceneManagement;
using UnityEditor.UIElements;

[CustomEditor(typeof(PosFixedItem),editorForChildClasses:true)]
public class PosFixedItemEditor : Editor
{
    private void OnSceneGUI()
    {

        //   Debug.Log(UnityEditor.Tools.current);
        if (UnityEditor.Tools.current != UnityEditor.Tool.Move)
        {
            return;
        }
        if (Application.isPlaying)
        {
            return;
        }
        Event e = Event.current;

        if (e.type == EventType.MouseUp && e.button == 0)
        {
            ChangePos();
            Debug.Log("Left Mouse was pressed");
           // var item = this.target as PosFixedItem;

        }

    }
    void ChangePos()
    {
        var item = this.target as PosFixedItem;
        var tp = item.UploadInstanceField();
        item.DownloadInstanceField(tp);

    }

   /* public override void OnInspectorGUI()
    {
        if (GUILayout.Button("Rotate"))
        {
            var item = this.target as ItemBase;
            var rotation = item.transform.localEulerAngles;
            rotation.z += 90;
            item.transform.localEulerAngles = rotation;
        }
        if (GUILayout.Button("HorizenalFlip"))
        {
            var item = this.target as ItemBase;
            var scale = item.transform.localScale;
            scale.x *= -1;
            item.transform.localScale = scale;
        }
        base.OnInspectorGUI();
        if (Application.isPlaying)
        {
            return;
        }
        // Debug.Log("!!!!");
        var list = GameObject.FindObjectsOfType<ItemBase>();
        var obj = GameObject.Find("GameManager");
        foreach (var x in list)
        {

            foreach (var v in x.PointList)
            {
                v.BelongingItem = x;
            }
        }
    }*/
}
